#define __1380_c
#include    "includeAll.h"
//鍐欐暟鎹�鍑芥暟:

void write1380CHUSHIHUA(unsigned char waddr,unsigned char wdat)
{
	 unsigned char i;
	P2MOD&=b1111_0011;
	P2MOD|=b0000_1000;
    rst=1;//浣胯兘
    for(i=0; i<8; i++)
    {
        io=(waddr&0x01)?1:0;//鍏堝啓鍦板潃锛屼粠浣庝綅寮€濮嬪啓
        sclk=1;//涓婂崌娌垮啓鏁版嵁
       
        sclk=0;
        waddr>>=1;//鍙崇Щ鍙栦笅涓€浣�
    }
    for(i=0; i<8; i++)
    {
		if(i==7)
		{
			io=0;
		}
		else
		{
			if(wdat&0x01==1)
			{
				io=1;
			}
			else
			{
				io=0;
			}
			
		}
         wdat>>=1;//鍙崇Щ鍙栦笅涓€浣�
        sclk=1;//涓婂崌娌垮啓鏁版嵁
       
        sclk=0;
        //wdat>>=1;//鍙崇Щ鍙栦笅涓€浣�
    }
    rst=0;//绂佹��
}

void Write1380(unsigned char waddr,unsigned char wdat)
{
    unsigned char i;
	
	
	P2MOD&=b1111_0011;
	P2MOD|=b0000_1000;
    rst=1;//浣胯兘
    for(i=0; i<8; i++)
    {
        io=(waddr&0x01)?1:0;//鍏堝啓鍦板潃锛屼粠浣庝綅寮€濮嬪啓
        sclk=1;//涓婂崌娌垮啓鏁版嵁
       
        sclk=0;
        waddr>>=1;//鍙崇Щ鍙栦笅涓€浣�
    }
    for(i=0; i<8; i++)
    {
        io=(wdat&0x01)?1:0;//鍐欐暟鎹�锛屼粠浣庝綅寮€濮嬪啓
        sclk=1;//涓婂崌娌垮啓鏁版嵁
       
        sclk=0;
        wdat>>=1;//鍙崇Щ鍙栦笅涓€浣�
    }
    rst=0;//绂佹��
}

//璇绘暟鎹�鍑芥暟:
unsigned char Read1380(unsigned char raddr)
{
	
    unsigned char i,rdat=0;
	
    rst=1;//浣胯兘
    for(i=0; i<8; i++) //鍐欏湴鍧€鍛戒护瀛楄妭
    {
		P2MOD&=b1111_0011;
	P2MOD|=b0000_1000;
        io=(raddr&0x01)?1:0;
        sclk=1;//涓婂崌娌垮啓鏁版嵁
       
        sclk=0;
        raddr>>=1;//鍙崇Щ鍙栦笅涓€浣�
    }
    for(i=0; i<8; i++) //璇绘暟鎹�
    {
		
		P2MOD&=b1111_0011;
		P2MOD|=b0000_0000;
		io=1;
        sclk=1;//涓婂崌娌胯�绘暟鎹�
      
        rdat>>=1;//鍙崇Щ涓€浣�
        if(io==1) rdat|=0x80;//浠庝綆浣嶅紑濮嬭�诲彇鏀惧叆鍙橀噺
        //else rdat|=0x00;//濡傛灉鏄�0锛屽彲浠ヤ笉浣滃�勭悊
        sclk=0;
    }
    rst=0;//绂佹��
    return rdat;
}